import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:jiaju_flutter/widgets/image/comm_image.dart';

const List<String> defaultImages = [
  "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fs9.sinaimg.cn%2Fbmiddle%2F436277f8ga8458f989968%26690&refer=http%3A%2F%2Fs9.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1627885615&t=c8479d1c51f6103089e93b8794ad9739",
  "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong.com%2F61%2F98%2F01300000248068123885985729957.jpg&refer=http%3A%2F%2Fa3.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1627885615&t=546ba21c4eb89231603ff41618f6992d",
  "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fblog.sina.com.cn%2Fpic%2F44f59d727e4f484157caa&refer=http%3A%2F%2Fblog.sina.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1627885615&t=be671983b1bd48cabb435c0b84380487"
];

class CommSwiper extends StatelessWidget {
  final List<String> images;
  final double height;

  const CommSwiper({Key key, this.images = defaultImages, this.height = 200.0})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height,
      width: double.infinity,
      child: Swiper(
        scrollDirection: Axis.horizontal,
        itemCount: images.length,
        itemBuilder: (BuildContext context, int index) {
          return CommImage(
            images[index],
            fit: BoxFit.fill,
          );
        },
        pagination: SwiperPagination(),
        control: SwiperControl(),
      ),
    );
  }
}
